<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改渠道业务关系')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-chabusir-edit" th:object="${hzChaBusiR}">
            <input name="rId" th:field="*{rId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">渠道：</label>
                <div class="col-sm-8">
                    <input name="extend_channelName" th:field="*{extend_channelName}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">业务：</label>
                <div class="col-sm-8">
                    <input name="extend_busiName" th:field="*{extend_busiName}" class="form-control" type="text" disabled>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">收费方式：</label>
                <div class="col-sm-8">
                    <select th:field="*{feeType}" th:value="*{feeType}" name="feeType" class="form-control">
                        <option th:selected="*{feeType==1}" value="1">单笔</option>
                        <option th:selected="*{feeType==2}" value="2">费率</option>
                        <option th:selected="*{feeType==3}" value="3">费率+单笔</option>
                    </select>
                </div>
            </div>
            <div class="form-group" id="fe1">
                <label class="col-sm-3 control-label" id="f1">单笔费用(单位:元)：</label>
                <div class="col-sm-8">
                    <input name="fee1" id="fee1" th:value="*{extend_fee1}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group" id="fe2">
                <label class="col-sm-3 control-label" id="f2">费率费用(单位:‰)：</label>
                <div class="col-sm-8">
                    <input name="fee2"  id="fee2" th:value="*{extend_fee2}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">启用状态：</label>
                <div class="col-sm-8">
                    <select th:field="*{status}" th:value="*{status}" name="status" class="form-control">
                        <option th:selected="*{status==1}" value="1">启用</option>
                        <option th:selected="*{status==2}" value="2">暂停</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "mng/chabusir";
        $("#form-chabusir-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-chabusir-edit').serialize());
            }
        }

        $("#feeType").change(function () {
        var selectedId = $("#feeType option:selected").val();
        if (selectedId == 1) {
            $("#fe1").show()
             $("#fe2").hide()
            $("#f1").text("单笔费用(单位:元)：")
        } else if (selectedId == 2) {
            $("#fe1").hide()
            $("#fe2").show()
            $("#f2").text("费率费用(单位:‰)：")
        } else if (selectedId == 3) {
            $("#fe1").show()
            $("#fe2").show()
            $("#f1").text("单笔费用(单位:元)：")
            $("#f2").text("费率费用(单位:‰)：")
        }
    });

    $(function () {
        var feeType = $("#feeType option:selected").val();
        if (feeType == 1) {
            $("#fe1").show()
            $("#fe2").hide()
            $("#f1").text("单笔费用(单位:元)：")
        } else if (feeType == 2) {
            $("#fe1").hide()
            $("#fe2").show()
            $("#f2").text("费率费用(单位:‰)：")
        } else if (feeType == 3) {
            $("#fe1").show()
            $("#fe2").show()
            $("#f1").text("单笔费用(单位:元)：")
            $("#f2").text("费率费用(单位:‰)：")
        }
    });
    </script>
</body>
</html>